//
//  Scene_Game.m
//  Return Of The Lemi
//
//  Created by Paul Vishayanuroj on 11/1/09.
//  Copyright 2009 Cornell University. All rights reserved.
//

#import "Scene_Game.h"
#import "Layer_Creatures.h"
#import "Layer_Background.h"
#import "Layer_Tiles.h"
#import "Layer_HUD.h"

@implementation Scene_Game

// Initialize the scene instance
- (id) init 
{
	if((self = [super init])) 
	{
		ParallaxNode *voidNode = [ParallaxNode node];
		Layer_Background *backgroundLayer = [Layer_Background node];
		Layer_Creatures *creatureLayer = [Layer_Creatures node];
		Layer_Tiles	*tileLayer = [Layer_Tiles node];
		Layer_HUD *hudLayer = [Layer_HUD node];

		// Add layers as children of the parallax node
		[voidNode addChild:backgroundLayer z:-1 parallaxRatio:ccp(0.4f,0.5f) positionOffset:CGPointZero];
		[voidNode addChild:tileLayer z:0 parallaxRatio:ccp(1.0f,1.0f) positionOffset:ccp(0,0)];
		[voidNode addChild:creatureLayer z:1 parallaxRatio:ccp(1.0f, 1.0f) positionOffset:ccp(0, 0)];

		[self addChild:voidNode z:0 tag:kTagParallaxNode];		
		[self addChild:hudLayer z:1 tag:kTagHUD];
		
		[hudLayer AddButtons];
	}
	return self;
}

- (void) Move:(CGPoint)point
{
	CocosNode *node = [self getChildByTag:kTagParallaxNode];
	CGPoint nodePos = [node position];	

	
	CGPoint viewCenter = CGPointMake(CONST_PLAYER_START_X, CONST_PLAYER_START_Y);
	CGPoint prevSpritePos = ccpSub(viewCenter, nodePos);
	

	CGPoint diff = ccpSub(prevSpritePos, point);
	[node setPosition: ccpAdd(nodePos, diff)];
}


@end


